package com.diandiansong.app.entity;

import com.google.gson.annotations.SerializedName;

import java.util.List;

import diandiansong.library.utils.BaseEntity;

public class ComodityViewInfo extends BaseEntity {

    /**
     * message : null
     * data : {"commodity_id":"35","commodity_name":"空心菜","commodity_subtitle":"纯天然绿色蔬菜","imgs":["http://h3.mobilekoudai
     * .com/uploads/2018-07-26/62067781f3aebb65c16b5942c8d3aa3ae8.jpg","http://h3.mobilekoudai
     * .com/uploads/2018-07-26/3d9d45c396dd0e151615307ee41633699b.jpg"],"price":"0.01","stock":"996","content":"回味无穷啊！","unit":"斤",
     * "kill_price":"0","sku":[{"product_id":"14","price":"0.01","store":"498","spec_info":"小+1斤，2斤，3斤，","kill_price":"0"},{"product_id":"15",
     * "price":"0.01","store":"498","spec_info":"中+1斤，2斤，3斤，","kill_price":"0"}],"collection":"0"}
     */

    @SerializedName("data")
    private Data data;

    public Data getData() {
        return data;
    }

    public void setData(Data data) {
        this.data = data;
    }

    public static class Data {
        /**
         * commodity_id : 35
         * commodity_name : 空心菜
         * commodity_subtitle : 纯天然绿色蔬菜
         * imgs : ["http://h3.mobilekoudai.com/uploads/2018-07-26/62067781f3aebb65c16b5942c8d3aa3ae8.jpg","http://h3.mobilekoudai
         * .com/uploads/2018-07-26/3d9d45c396dd0e151615307ee41633699b.jpg"]
         * price : 0.01
         * stock : 996
         * content : 回味无穷啊！
         * unit : 斤
         * kill_price : 0
         * sku : [{"product_id":"14","price":"0.01","store":"498","spec_info":"小+1斤，2斤，3斤，","kill_price":"0"},{"product_id":"15","price":"0.01",
         * "store":"498","spec_info":"中+1斤，2斤，3斤，","kill_price":"0"}]
         * collection : 0
         */

        @SerializedName("commodity_id")
        private String commodityId;
        @SerializedName("commodity_name")
        private String commodityName;
        @SerializedName("commodity_subtitle")
        private String commoditySubtitle;
        @SerializedName("price")
        private String price;
        @SerializedName("stock")
        private String stock;
        @SerializedName("content")
        private String content;
        @SerializedName("unit")
        private String unit;
        @SerializedName("kill_price")
        private String killPrice;
        @SerializedName("collection")
        private String collection;
        @SerializedName("imgs")
        private List<String> imgs;
        @SerializedName("sku")
        private List<Sku> sku;


        @SerializedName("purchase")
        private String purchase;
        @SerializedName("purchase_name")
        private String purchaseName;
        @SerializedName("purchase_types")
        private String purchase_types;


        @SerializedName("tourist")
        private String tourist;

        @SerializedName("gift")
        private String gift;

        public boolean isTourist() {
            return tourist != null && tourist.equals("1");
        }

        public String getCommodityId() {
            return commodityId;
        }

        public void setCommodityId(String commodityId) {
            this.commodityId = commodityId;
        }

        public String getCommodityName() {
            return commodityName;
        }

        public void setCommodityName(String commodityName) {
            this.commodityName = commodityName;
        }

        public String getCommoditySubtitle() {
            return commoditySubtitle;
        }

        public void setCommoditySubtitle(String commoditySubtitle) {
            this.commoditySubtitle = commoditySubtitle;
        }

        public String getPrice() {
            if (isTourist()) {
                //return "--";
                return "";
            }
            return price;
        }

        public Float getPriceF() {
            try {
                return Float.valueOf(price);
            } catch (Exception e) {
                return 1f;
            }
        }

        public void setPrice(String price) {
            this.price = price;
        }

        public String getStock() {
            return stock;
        }

        public void setStock(String stock) {
            this.stock = stock;
        }

        public String getContent() {
            return content;
        }

        public void setContent(String content) {
            this.content = content;
        }

        public String getUnit() {
            return unit;
        }

        public void setUnit(String unit) {
            this.unit = unit;
        }

        public String getKillPrice() {
            if (isTourist()) {
                //return "--";
                return "";
            }
            return killPrice;
        }

        public Float getKillPriceF() {
            try {
                return Float.valueOf(killPrice);
            } catch (Exception e) {
                return 0f;
            }
        }

        public void setKillPrice(String killPrice) {
            this.killPrice = killPrice;
        }

        public boolean isCollection() {
            return collection != null && collection.equals("1");
        }

        public void setCollection(String collection) {
            this.collection = collection;
        }

        public List<String> getImgs() {
            return imgs;
        }

        public void setImgs(List<String> imgs) {
            this.imgs = imgs;
        }

        public List<Sku> getSku() {
            return sku;
        }

        public void setSku(List<Sku> sku) {
            this.sku = sku;
        }

        public String getGift() {
            return gift;
        }

        public void setGift(String gift) {
            this.gift = gift;
        }

        public int getPurchase() {
            try {
                return Integer.valueOf(purchase);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return 0;
        }

        public void setPurchase(String purchase) {
            this.purchase = purchase;
        }

        public String getPurchaseName() {
            return purchaseName;
        }

        public void setPurchaseName(String purchaseName) {
            this.purchaseName = purchaseName;
        }

        /**
         * 0 普通限购
         * 1 秒杀限购
         *
         * @return
         */
        public boolean isPurchaseTypesLimit() {
            return purchase_types != null && purchase_types.equals("1");
        }

        public void setPurchase_types(String purchase_types) {
            this.purchase_types = purchase_types;
        }

        public static class Sku {
            /**
             * product_id : 14
             * price : 0.01
             * store : 498
             * spec_info : 小+1斤，2斤，3斤，
             * kill_price : 0
             */

            @SerializedName("product_id")
            private String productId;
            @SerializedName("price")
            private String price;
            @SerializedName("store")
            private String store;
            @SerializedName("spec_info")
            private String specInfo;
            @SerializedName("kill_price")
            private String killPrice;

            @SerializedName("purchase")
            private String purchase;
            @SerializedName("purchase_name")
            private String purchaseName;

            public String getProductId() {
                return productId;
            }

            public void setProductId(String productId) {
                this.productId = productId;
            }

            public String getPrice() {
                return price;
            }

            public Float getPriceF() {
                try {
                    return Float.valueOf(price);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return 1f;
            }

            public void setPrice(String price) {
                this.price = price;
            }

            public String getStore() {
                return store;
            }

            public void setStore(String store) {
                this.store = store;
            }

            public String getSpecInfo() {
                return specInfo;
            }

            public void setSpecInfo(String specInfo) {
                this.specInfo = specInfo;
            }

            public String getKillPrice() {
                return killPrice;
            }

            public Float getKillPriceF() {
                try {
                    return Float.valueOf(killPrice);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return 1f;
            }

            public void setKillPrice(String killPrice) {
                this.killPrice = killPrice;
            }


            public int getPurchase() {
                try {
                    return Integer.valueOf(purchase);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return 0;
            }

            public void setPurchase(String purchase) {
                this.purchase = purchase;
            }

            public String getPurchaseName() {
                return purchaseName;
            }

            public void setPurchaseName(String purchaseName) {
                this.purchaseName = purchaseName;
            }
        }
    }
}